import { NextApiRequest, NextApiResponse } from "next";
import { createUserData } from "@/lib/userdata_database_method";


export default async function handler(req: NextApiRequest, res: NextApiResponse) {
    // 设置 CORS 头部
    res.setHeader('Access-Control-Allow-Origin', '*'); // 允许所有来源
    console.log(req.body);
    const { username, email, password } = req.body;

    try {
        createUserData(username, email, password);
        res.status(200).json({ message: "新用户数据创建成功" });

    } catch (error) {
        console.log(error);
    }

}